package utils;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;

import java.nio.charset.StandardCharsets;

/**
 * 使用 hutool 工具类实现的AES加密
 * @Author: lyy
 * Date: 2021/12/15 17:10
 */
public class AesUtil {

	private static final String KEY = "0CoJUm6Qyw8W8jud";

	public static String encrypt(String content){
		AES aes = new AES(Mode.ECB, Padding.PKCS5Padding, KEY.getBytes());
		return aes.encryptHex(content);
	}

	public static String decrypt(String encryptHex){
		AES aes = new AES(Mode.ECB, Padding.PKCS5Padding, KEY.getBytes());
		return aes.decryptStr(encryptHex, StandardCharsets.UTF_8);
	}

}
